﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Admin_Default"  MasterPageFile="~/Masterpage/AdminSite.Master"%>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>


<asp:Content ContentPlaceHolderID="MainContent" ID="maincontent1" runat="Server">
 
    <asp:HiddenField ID="HiddenField1" runat="server" />

    <div class="newsbox_noleft">
    <div class="newsbox_noleft_content">
        <table class="style1">
            <tr>
            <td>Danh mục chính:</td>
            <td><asp:DropDownList ID="DropDownList1" runat="server" 
                    AutoPostBack="True" DataSourceID="SqlDataSource2" 
                    DataTextField="TenDanhMucChinh" DataValueField="MaDanhMucChinh" 
                    Height="30px" Width="200px">
                    
                </asp:DropDownList>
                </td>
                <td>
                                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
                    SelectCommand="SELECT [MaDanhMucChinh], [TenDanhMucChinh] FROM [DANH_MUC_CHINH] WHERE ([Deleted] = @Deleted)">
                                        <SelectParameters>
                                            <asp:Parameter DefaultValue="false" Name="Deleted" Type="Boolean" />
                                        </SelectParameters>
                </asp:SqlDataSource>
                                    </td>
                                    </tr>
                                            <td>Danh mục cọn: </td>
            <td>
                <asp:DropDownList ID="DropDownList2" runat="server" 
                    DataSourceID="SqlDataSource3" DataTextField="TenDanhMucCon" 
                    DataValueField="MaDanhMucCon" Height="30px" Width="200px">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
                    
                    SelectCommand="SELECT [MaDanhMucCon], [TenDanhMucCon] FROM [DANH_MUC_CON] WHERE (([Deleted] = @Deleted) AND ([MaDanhMucChinh] = @MaDanhMucChinh))">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="false" Name="Deleted" Type="Boolean" />
                        <asp:ControlParameter ControlID="DropDownList1" Name="MaDanhMucChinh" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
                </td>
                    <tr>
                              <td>

                                  Thời gian: </td>
                                  <td>
                    <asp:DropDownList ID="dropThoiGian" runat="server" Height="30px" Width="200px" 

                                      >
                        <asp:ListItem Value="1000000">---Tất cả---</asp:ListItem>
                        <asp:ListItem Value="1">24 giờ qua</asp:ListItem>
                        <asp:ListItem Value="7">1 tuần qua</asp:ListItem>
                        <asp:ListItem Value="30">1 tháng qua</asp:ListItem>
                        <asp:ListItem Value="365">1 năm qua</asp:ListItem>
                    </asp:DropDownList>
                </td>
               
            </tr>
                        <tr>
            <td style="width: 104px">Xem các loại tin:</td>
              <td>
                <asp:CheckBox ID="ckLayTatCa" CssClass="test"  runat="server" Text="Tất cả" />
                </td>
            <td><asp:CheckBox ID="ckDuyet" runat="server" Text="Duyệt" />
                                    </td>
            <td><asp:CheckBox ID="ckViPham" runat="server" Text="Vi Phạm"/>
                                    </td>
            <td>&nbsp;</td>
            <td>
                &nbsp;</td>
                <td>
                </td>
          
            </tr>
                            <Tr> <td></td>
                                           <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click1" 
                        Text="Tìm" CssClass="exclusive" />
                </td>
                </Tr>

           </table>
                
            <br />
              <br />
                <br />
                 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="MaTinRaoVat" DataSourceID="SqlDataSource5" CellPadding="3" 
            ForeColor="Black" GridLines="Vertical" AllowPaging="True" 
 AllowSorting="True" onrowdatabound="GridView1_RowDataBound" 
            BackColor="White" 
            EnableModelValidation="True" Width="732px" BorderColor="White">
            <AlternatingRowStyle BackColor="#CCCCCC" />
                        <RowStyle Height="60px" HorizontalAlign="Center" VerticalAlign="Middle" />
            <Columns>
                <asp:BoundField DataField="MaTinRaoVat" HeaderText="MaTinRaoVat" 
                    InsertVisible="False" SortExpression="MaTinRaoVat" 
                    Visible="False" />
                <asp:TemplateField HeaderText="Tên Tin" SortExpression="TenTinRaoVat">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TenTinRaoVat") %>' 
                            ReadOnly="True"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1" runat="server" 
                            NavigateUrl='<%# Eval("MaTinRaoVat", "~/RaoVat/ChiTietTinRaoVat.aspx?id={0}") %>' 
                            Text='<%# Eval("TenTinRaoVat") %>'></asp:HyperLink>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="200px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Tên người dùng">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" ReadOnly="True" 
                            Text='<%# Bind("TenNguoiDung") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:HyperLink ID="hplTenNguoiDung" runat="server" 
                            NavigateUrl='<%# Eval("MaNguoiDung", "~/Account/ThongTinLienHeNguoiDung.aspx?id={0}") %>' 
                            Text='<%# Eval("TenNguoiDung", "{0}") %>'></asp:HyperLink>
                    </ItemTemplate>
                    <ItemStyle Width="15%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Thời gian đăng" SortExpression="ThoiGianDang">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" ReadOnly="True" 
                            Text='<%# Bind("ThoiGianDang") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" 
                            Text='<%# Bind("ThoiGianDang", "{0:d}") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="10%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Số lần xem" SortExpression="SoLanXem">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox4" runat="server" ReadOnly="True" 
                            Text='<%# Bind("SoLanXem") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("SoLanXem") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="10%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Điểm bình chọn" SortExpression="DiemBinhChonTB">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox5" runat="server" ReadOnly="True" 
                            Text='<%# Bind("DiemBinhChonTB") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("DiemBinhChonTB") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="10%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Đã duyệt" SortExpression="DaDuyet">
                   
                    <ItemTemplate>
                        <asp:UpdatePanel runat="Server">
                   <ContentTemplate>
                         <asp:CheckBox ID="ckDaDuyet" runat="server" Checked='<%# Bind("DaDuyet") %>' 
                         oncheckedchanged="ckDaDuyet_CheckedChanged" 
                            ToolTip='<%# Eval("MaTinRaoVat", "{0}") %>' AutoPostBack="True" Enabled="true" />
                      </ContentTemplate>
                            </asp:UpdatePanel>
                       
                    </ItemTemplate>
                    <ItemStyle Width="5%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Vi phạm" SortExpression="ViPham">
                    
                    <ItemTemplate>
                   <asp:UpdatePanel runat="Server">
                   <ContentTemplate>
                        <asp:CheckBox ID="ckViPhamColumn" runat="server" Checked='<%# Bind("ViPham") %>' 
                           
                            oncheckedchanged="ckViPham_CheckedChanged" 
                            ToolTip='<%# Eval("MaTinRaoVat", "{0}") %>' AutoPostBack="True" />
                            </ContentTemplate>
                            </asp:UpdatePanel>
                            
                    </ItemTemplate>
                    <ItemStyle Width="5%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Deleted" SortExpression="Deleted">
                    <EditItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Deleted") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Deleted") %>' 
                            oncheckedchanged="CheckBox1_CheckedChanged" 
                            ToolTip='<%# Eval("MaTinRaoVat", "{0}") %>' AutoPostBack="True" />
                    </ItemTemplate>
                    <ItemStyle Width="5%" />
                </asp:TemplateField>
            </Columns>
             <FooterStyle BackColor="#CCCCCC" />
                        <PagerStyle BackColor="#666666" ForeColor="Black" HorizontalAlign="Center" 
                         Font-Size="Medium" Height="30px" 
                            VerticalAlign="Middle" />
                        <EmptyDataTemplate>
                            <asp:Label ID="Label1" runat="server" Text="Không tìm thấy dữ liệu liên quan"></asp:Label>
                        </EmptyDataTemplate>
                        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#666666" Font-Bold="True" ForeColor="White" HorizontalAlign="Center"
                            VerticalAlign="Middle" Height="60px" Width="200px" />
          </asp:GridView>
           
       
                  
              
                
                   
        
        
      
          
        <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
            ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
           SelectCommand="SELECT TIN_RAO_VAT.MaTinRaoVat, TIN_RAO_VAT.TenTinRaoVat, TIN_RAO_VAT.ThoiGianDang, TIN_RAO_VAT.SoLanXem, TIN_RAO_VAT.DiemBinhChonTB, TIN_RAO_VAT.DaDuyet, TIN_RAO_VAT.ViPham, NGUOI_DUNG.TenNguoiDung, NGUOI_DUNG.MaNguoiDung, TIN_RAO_VAT.Deleted FROM TIN_RAO_VAT INNER JOIN NGUOI_DUNG ON TIN_RAO_VAT.MaNguoiDung = NGUOI_DUNG.MaNguoiDung WHERE (TIN_RAO_VAT.Deleted = 0) AND (TIN_RAO_VAT.DaDuyet = @DaDuyet) AND (TIN_RAO_VAT.ViPham = @ViPham) AND (TIN_RAO_VAT.MaDanhMucCon = @MaDanhMucCon) AND (DATEDIFF(D, TIN_RAO_VAT.ThoiGianDang, @ThoiGianHienTai) &lt;= @DropThoiGian)" 
           
            
            
            UpdateCommand="UPDATE [TIN_RAO_VAT] SET [ViPham] = @ViPham, [DaDuyet] = @DaDuyet WHERE [MaTinRaoVat] = @MaTinRaoVat">
           
            <SelectParameters>
                <asp:ControlParameter ControlID="ckDuyet" Name="DaDuyet" 
                    PropertyName="Checked" DefaultValue="0" />
                <asp:ControlParameter ControlID="ckViPham" Name="ViPham" 
                    PropertyName="Checked" DefaultValue="1" />
                <asp:ControlParameter ControlID="DropDownList2" DefaultValue="0" 
                    Name="MaDanhMucCon" PropertyName="SelectedValue" />
                <asp:ControlParameter ControlID="HiddenField1" DefaultValue="" 
                    Name="ThoiGianHienTai" PropertyName="Value" />
                <asp:ControlParameter ControlID="dropThoiGian" Name="DropThoiGian" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
            
            <UpdateParameters>
                <asp:Parameter Name="ViPham" Type="Boolean" />
                <asp:Parameter Name="DaDuyet" Type="Boolean" />
                <asp:Parameter Name="MaTinRaoVat" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
       
       
                  
              
                
                   
        
        
      
          
        <asp:SqlDataSource ID="SqlDataSource5" runat="server" 
            ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
           SelectCommand="SELECT TIN_RAO_VAT.MaTinRaoVat, TIN_RAO_VAT.TenTinRaoVat, TIN_RAO_VAT.ThoiGianDang, TIN_RAO_VAT.SoLanXem, TIN_RAO_VAT.DiemBinhChonTB, TIN_RAO_VAT.DaDuyet, TIN_RAO_VAT.ViPham, NGUOI_DUNG.TenNguoiDung, NGUOI_DUNG.MaNguoiDung, TIN_RAO_VAT.Deleted FROM TIN_RAO_VAT INNER JOIN NGUOI_DUNG ON TIN_RAO_VAT.MaNguoiDung = NGUOI_DUNG.MaNguoiDung ORDER BY TIN_RAO_VAT.ThoiGianDang DESC" 
           
            
            
            UpdateCommand="UPDATE [TIN_RAO_VAT] SET [ViPham] = @ViPham, [DaDuyet] = @DaDuyet WHERE [MaTinRaoVat] = @MaTinRaoVat">
           
            <UpdateParameters>
                <asp:Parameter Name="ViPham" Type="Boolean" />
                <asp:Parameter Name="DaDuyet" Type="Boolean" />
                <asp:Parameter Name="MaTinRaoVat" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
       
        <br />
      
          
          <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
            DeleteCommand="DELETE FROM [TIN_RAO_VAT] WHERE [MaTinRaoVat] = @MaTinRaoVat" 
            InsertCommand="INSERT INTO [TIN_RAO_VAT] ([TenTinRaoVat], [ThoiGianDang], [SoLanXem], [DiemBinhChonTB], [DaDuyet], [ViPham]) VALUES (@TenTinRaoVat, @ThoiGianDang, @SoLanXem, @DiemBinhChonTB, @DaDuyet, @ViPham)" 
            SelectCommand="SELECT TIN_RAO_VAT.MaTinRaoVat, TIN_RAO_VAT.TenTinRaoVat, TIN_RAO_VAT.ThoiGianDang, TIN_RAO_VAT.SoLanXem, TIN_RAO_VAT.DiemBinhChonTB, TIN_RAO_VAT.DaDuyet, TIN_RAO_VAT.ViPham, NGUOI_DUNG.TenNguoiDung, TIN_RAO_VAT.Deleted FROM TIN_RAO_VAT INNER JOIN NGUOI_DUNG ON TIN_RAO_VAT.MaNguoiDung = NGUOI_DUNG.MaNguoiDung WHERE (TIN_RAO_VAT.Deleted = 0) AND (TIN_RAO_VAT.DaDuyet = 0)" 
            
            
            
            UpdateCommand="UPDATE [TIN_RAO_VAT] SET [DaDuyet] = @DaDuyet, [ViPham] = @ViPham WHERE [MaTinRaoVat] = @MaTinRaoVat">
            <DeleteParameters>
                <asp:Parameter Name="MaTinRaoVat" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="TenTinRaoVat" Type="String" />
                <asp:Parameter Name="ThoiGianDang" Type="DateTime" />
                <asp:Parameter Name="SoLanXem" Type="Int32" />
                <asp:Parameter Name="DiemBinhChonTB" Type="Double" />
                <asp:Parameter Name="DaDuyet" Type="Boolean" />
                <asp:Parameter Name="ViPham" Type="Boolean" />
            </InsertParameters>
            <UpdateParameters>
               
                <asp:Parameter Name="DaDuyet" Type="Boolean" />
                <asp:Parameter Name="ViPham" Type="Boolean" />
                <asp:Parameter Name="MaTinRaoVat" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
       
     </div>
       
   </div>
    
</asp:Content>